<?php

namespace app\admin\model\scanwork;

use think\Model;

class IndustryConfig extends Model
{
    protected $name = 'scanwork_industry_config';
    
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'industry_type_text',
        'status_text'
    ];

    public function getIndustryTypeList()
    {
        return [
            'discrete' => '离散制造',
            'process' => '流程制造',
            'hybrid' => '混合制造'
        ];
    }

    public function getStatusList()
    {
        return [
            'normal' => '正常',
            'hidden' => '隐藏'
        ];
    }

    public function getIndustryTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['industry_type']) ? $data['industry_type'] : '');
        $list = $this->getIndustryTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }
}

